

#import "NSMDateFormatter.h"

@implementation NSMDateFormatter

+ (instancetype)shareInstance
{
    static NSMDateFormatter *_shareInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _shareInstance = [[NSMDateFormatter alloc] init];
    });
    return _shareInstance;
}

- (NSString *)stringFromTimeInterval:(double)seconds
{
    NSDate *tempDate = [NSDate dateWithTimeIntervalSince1970:seconds];
    // yyyy-MM-dd HH:mm:ss zzz (zzz表示时区,zzz可以删除.这样返回的日期字符将不包含时区信息)
//    self.dateFormat = @"yyyy-MM-dd HH:mm";
    self.dateFormat = @"yyyy-MM-dd";

    
    return [self stringFromDate:tempDate];
}

- (NSString *)stringFromDate:(NSDate *)date format:(NSString *)dateFormat
{
    self.dateFormat = dateFormat;
    return [self stringFromDate:date];
}

- (NSString *)stringFromTimeInterval:(double)seconds format:(NSString *)dateFormat
{
    NSDate *tempDate = [NSDate dateWithTimeIntervalSince1970:seconds];
    
    return [self stringFromDate:tempDate format:dateFormat];
}

@end
